using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;


namespace Pitoshka.Web
{
	//<httpModules>
	//    <add name="ErrorHandler" type="ErrorHandler"/>
	//</httpModules>
	public class ErrorHandler : IHttpModule
	{
		private HttpContext m_ApplicationContext;

		public ErrorHandler(){}

		#region IHttpModule Members
		public void Dispose()
		{
		}
		public void Init(HttpApplication context)
		{
			m_ApplicationContext = context.Context;
			m_ApplicationContext.ClearError();
			context.Error += new EventHandler(context_Error);
		}
		protected void context_Error(object sender, EventArgs e)
		{
			/* Here , I am not getting any of the object initialized  */
			
			Exception firstError = m_ApplicationContext.Error.GetBaseException();
			Exception[] ExpArr = m_ApplicationContext.AllErrors;
			Exception NewException = m_ApplicationContext.Server.GetLastError().GetBaseException(); //Log new 
		}
		#endregion
	}
}
